package com.zhongketech.sunflower.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public abstract class ListAdapter extends BaseAdapter {
	protected List mDataList;
	protected Context mContext;

	public ListAdapter(Context context, List list) {
		if (null == list) {
			throw new IllegalArgumentException("data list should not be null");
		}
		mDataList = list;
		mContext = context;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mDataList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mDataList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		return createViewItem(position, convertView, parent);
	}

	public List getmDataList() {
		return mDataList;
	}

	public void setmDataList(List mDataList) {
		this.mDataList = mDataList;
		notifyDataSetChanged();
	}

	protected abstract View createViewItem(int position, View convertView, ViewGroup group);

}
